#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"QPixmap"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *event)
{    QPixmap pix(500,500);
    QPainter painter(&pix);//将图片作为画板
    QPen pen;
    pen.setColor(Qt::red);//设置颜色
    pen.setWidth(5);//设置线粗为5像素的
    pen.setStyle(Qt::DashLine);//设置虚线
    painter.setPen(pen);
    QRadialGradient gradient(QPointF(300,300),100,QPointF(300,300));//径向渐变
    gradient.setColorAt(0, Qt::yellow);
    gradient.setColorAt(0.5,Qt::blue);
    gradient.setColorAt(1, Qt::red);
    QBrush brush(gradient);//设置渐变色
    //brush.setColor(Qt::blue);//设置画刷
    //brush.setStyle(Qt::Dense1Pattern);//设置画刷样式类型
    painter.setBrush(brush);//
    painter.drawEllipse(200,200,200,200);

    pix.save("D:\\qtdown\\project\\pen\\pix.png");//存储形状作为图片放在当前目录下



}

